In video graphics applications, many techniques are used to render graphical images of different shapes and sizes. Typically, graphical images are made up of thousands, or even millions, of primitive shapes such as triangles. Each triangle is defined by the coordinates of its vertices. In order to enhance the three-dimensional aspects of a graphical rendering, texture may be added to each of the triangles or other drawing units. Texture coordinates are used to assign texture maps to each object as it is rendered on a display device. A texture map is an array of texture elements (texels) combined to form a standard block of texture.
Mapping textures to rendered objects can be complicated by the depths (i.e., distances relative to the viewer) of the various objects in a rendered scene. The orientation of the rendered objects can also affect the complexity of mapping the textures to the rendered objects. Furthermore, applying texture to a single object can be complicated if the object varies in depth and orientation on the display device.
In order to map a texture to an object, one or more texture maps may be arrayed across the surface area of the object. Different type of array patterns such as texture wrapping and texture mirror can be used. In each case, however, the coordinates for each texture map are calculated so that the several texture maps are rendered in the correct areas of the display.
Conventional techniques for implementing non-power of two texture coordinate wrapping and mirror patterns use a divider to divide a texture coordinate in texture space by a non-power of two texture map size to get the result. As an example, the following conventional equations are used:U′=(int(S*width))% width, andI=(int(S*width))/widthwhere S designates the floating-point texture coordinate, U′ designates an intermediate texture coordinate, I designates a fixed point integer component, and width designates a dimension of a texture map. The computation of the intermediate texture coordinate, U′, implements a remainder division operation (e.g., a modulo, or mod, operation), and the computation of the fixed point integer component, I, implements a quotient division operation.
For a texture coordinate wrapping pattern, the final texture coordinate, U, is calculated, according to the following:U=U′
For a texture coordinate mirror pattern, the final texture coordinate, U, is calculated, according to the following:U=U′ for I % 1=0, andU=width−U′ for I % 1=1,
In other words, the texture map is reversed, or mirrored, for alternating instances of the texture map in the array of texture maps across the surface area of the rendered object. Similar equations are implemented in the vertical direction, using the height of the texture map, instead of the width of the texture map.
Unfortunately, the implementation of the division operations—the remainder division operation to compute the intermediate texture coordinate, U′, and the quotient division operation to compute the fixed point integer component, I—is computationally expansive. Additionally, this configuration is expensive to implement in hardware because of the surface area consumed to implement these division operations